/**
 * Copyright © 2008, EMC Corporation.
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 *     + Redistributions of source code must retain the above copyright notice, 
 *       this list of conditions and the following disclaimer.
 *     + Redistributions in binary form must reproduce the above copyright 
 *       notice, this list of conditions and the following disclaimer in the 
 *       documentation and/or other materials provided with the distribution.
 *     + The name of EMC Corporation may not be used to endorse or promote 
 *       products derived from this software without specific prior written 
 *       permission.
 *
 *      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 *      "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
 *      TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 *      PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
 *      BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 *      CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 *      SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 *      INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *      CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 *      ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 *      POSSIBILITY OF SUCH DAMAGE.
 */
package com.emc.esu.api {
	import mx.logging.ILogger;
	import mx.logging.Log;
	
	
	public class DirectoryEntry {
		
		public function DirectoryEntry() {
			this.logger = Log.getLogger("EsuApi");
		}
		
		private var _path:ObjectPath;
		private var _id:ObjectId;
		private var _type:String;
		private var _children:Object;
		private var _userMetadadta:MetadataList;
		private var _systemMetadatda:MetadataList;
		
	    private var logger:ILogger;
	    
		/**
		 * @return the path
		 */
		public function getPath():ObjectPath {
			return _path;
		}
		/**
		 * @return the parsed name of the directory
		 */
		public function getName():String {
			var name:String = "";
			
			if (this._path != null) {
				var startIdx:int;
				if (this._path.isDirectory()) {
					if (this._path.toString().length > 2) {
						startIdx = this._path.toString().lastIndexOf("/", this._path.toString().length - 2) + 1;
						if (startIdx > 0 && startIdx < this._path.toString().length - 2)
							name = this._path.toString().substring(startIdx, this._path.toString().length - 1);
					}
				}
				else {
					startIdx = this._path.toString().lastIndexOf("/") + 1;
					name = this._path.toString().substring(startIdx);
				}
			}
			logger.debug(this._path.toString() + "  " + name);
			
			return name;
		}
		/**
		 * @param path the path to set
		 */
		public function setPath(path:ObjectPath):void {
			this._path = path;
		}
		/**
		 * @return the id
		 */
		public function getId():ObjectId {
			return _id;
		}
		/**
		 * @param id the id to set
		 */
		public function setId(id:ObjectId):void {
			this._id = id;
		}
		
		
		
		/**
		 * @return the type
		 */
		public function getType():String {
			return _type;
		}
		
		/**
		 * @param type the type to set
		 */
		public function setType(type:String):void {
			this._type = type;
		}
		
		/**
		 * @see java.lang.Object#toString()
		 */
		public function toString():String {
			// TODO Auto-generated method stub
			return _path + " - " + _type + " - " + _id;
		}
		
		public function get type():String {
			return this._type;
		}
		
		public function set type(t:String):void {
			this._type = t;
		}
		
		public function get path():ObjectPath {
			return this._path;
		}
		
		public function set path(p:ObjectPath):void {
			this._path = p;
		}
		
		public function get id():ObjectId {
			return this._id;
		}
		
		public function set id(i:ObjectId):void {
			this._id = i;
		}
		
		public function get children():Object {
			return this._children;
		}
		
		public function set children(list:Object):void {
			this._children = list;
		}
		
		public function get userMetadata():MetadataList {
			return _userMetadadta;
		}
		public function set userMetadata( value:MetadataList ):void {
			_userMetadadta = value;
		}
		
		public function get systemMetadata():MetadataList {
			return _systemMetadatda;
		}
		public function set systemMetadata( value:MetadataList ):void {
			_systemMetadatda = value;
		}
		
	}
}